package com.scm.service.impl;

import java.util.List;
import com.scm.common.utils.DateUtils;
import com.scm.persist.model.ScmInventoryStash;
import com.scm.persist.model.ScmInventoryStashExample;
import com.scm.persist.mybatis.ScmInventoryStashMapper;
import com.scm.service.IScmInventoryStashService;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.scm.common.core.text.Convert;

/**
 * 库存-仓库信息Service业务层处理
 * 
 * @author reptilemanager
 * @date 2024-03-09
 */
@Service
public class ScmInventoryStashServiceImpl implements IScmInventoryStashService
{
    @Autowired
    private ScmInventoryStashMapper scmInventoryStashMapper;

    /**
     * 查询库存-仓库信息
     * 
     * @param id 库存-仓库信息主键
     * @return 库存-仓库信息
     */
    @Override
    public ScmInventoryStash selectScmInventoryStashById(Long id)
    {
        return scmInventoryStashMapper.selectByPrimaryKey(id);
    }

    /**
     * 查询库存-仓库信息列表
     * 
     * @return 库存-仓库信息
     */
    @Override
    public List<ScmInventoryStash> selectScmInventoryStashList(ScmInventoryStash scmInventoryStash,Integer start, Integer size)
    {

        RowBounds rowBounds = new RowBounds(start,size);

        ScmInventoryStashExample example = new ScmInventoryStashExample();
        ScmInventoryStashExample.Criteria criteria = example.createCriteria();
        criteria.andStatusEqualTo("1");
        if(StringUtils.isNotEmpty(scmInventoryStash.getName())){
            criteria.andNameEqualTo(scmInventoryStash.getName());
        }

        if(StringUtils.isNotEmpty(scmInventoryStash.getContactPerson())){
            criteria.andContactPersonEqualTo(scmInventoryStash.getContactPerson());
        }

        return  scmInventoryStashMapper.selectByExampleWithRowbounds(example,rowBounds);
    }

    @Override
    public List<ScmInventoryStash> selectAllScmInventoryStashList() {

        ScmInventoryStashExample example = new ScmInventoryStashExample();
        example.setOrderByClause( " id desc ");
        return scmInventoryStashMapper.selectByExample(example);
    }

    /**
     * 新增库存-仓库信息
     * 
     * @param scmInventoryStash 库存-仓库信息
     * @return 结果
     */
    @Override
    public int insertScmInventoryStash(ScmInventoryStash scmInventoryStash)
    {
        return scmInventoryStashMapper.insertSelective(scmInventoryStash);
    }

    /**
     * 修改库存-仓库信息
     * 
     * @param scmInventoryStash 库存-仓库信息
     * @return 结果
     */
    @Override
    public int updateScmInventoryStash(ScmInventoryStash scmInventoryStash)
    {
        return scmInventoryStashMapper.updateByPrimaryKeySelective(scmInventoryStash);
    }

    /**
     * 批量删除库存-仓库信息
     * 
     * @param id 需要删除的库存-仓库信息主键
     * @return 结果
     */
    @Override
    public int deleteScmInventoryStashById(String id)
    {
        return scmInventoryStashMapper.deleteByPrimaryKey(Long.valueOf(id));
    }

    /**
     * 删除库存-仓库信息信息
     * 
     * @param id 库存-仓库信息主键
     * @return 结果
     */
    @Override
    public int deleteScmInventoryStashById(Long id)
    {
        return scmInventoryStashMapper.deleteByPrimaryKey(id);
    }
}
